// Material color helpers including text color and background color

$mat-colors: (
  red: $mat-red,
  pink: $mat-pink,
  purple: $mat-purple,
  deep-purple: $mat-deep-purple,
  indigo: $mat-indigo,
  blue: $mat-blue,
  light-blue: $mat-light-blue,
  cyan: $mat-cyan,
  teal: $mat-teal,
  green: $mat-green,
  light-green: $mat-light-green,
  lime: $mat-lime,
  yellow: $mat-yellow,
  amber: $mat-amber,
  orange: $mat-orange,
  deep-orange: $mat-deep-orange,
  brown: $mat-brown,
  gray: $mat-gray,
  blue-gray: $mat-blue-gray,
  white: white,
  black: black,
  light: $light-primary-text,
  dark: $dark-primary-text,
);

@mixin generate-color($prefix, $property) {
  @each $name, $value in $mat-colors {
    // If the value is a map, continue to each
    @if type-of($value) == 'map' {
      @each $hue, $color in $value {
        @if ($hue != 'contrast') {
          .#{$prefix + '-' + $name + '-' + $hue} {
            #{$property}: $color !important;
          }
        }
        // alias
        @if ($name == 'gray') {
          .#{$prefix + '-grey-' + $hue} {
            @extend .#{$prefix + '-gray-' + $hue} !optional;
          }
        }

        @if ($name == 'blue-gray') {
          .#{$prefix + '-blue-grey-' + $hue} {
            @extend .#{$prefix + '-blue-gray-' + $hue} !optional;
          }
        }
      }
    }

    @if type-of($value) == 'color' {
      .#{$prefix + '-' + $name} {
        #{$property}: $value !important;
      }
    }
  }
}

@include generate-color('text', 'color');
@include generate-color('bg', 'background-color');
